import { listSlice } from '../redux/store'
import { useDispatch, useSelector, TypedUseSelectorHook } from 'react-redux'
import { RootState, AppDispatch } from '../redux/store'

const useAppSelector: TypedUseSelectorHook<RootState> = useSelector
const useAppDispatch = () => useDispatch<AppDispatch>()
export default function List() {
  const dispatch = useAppDispatch()
  const state = useAppSelector((state) => {
    return state.list
  })
  return (
    <div>
      <button
        onClick={() => {
          dispatch(listSlice.actions.push("e"))
        }}
      >点击增加数组</button>

      <ul>
        {state.arr.map((item, index) => {
          return <li key={index}>{item}</li>
        })}
      </ul>
    </div>
  )
}
